/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * QLTRASACH.java
 *
 * Created on Oct 20, 2010, 10:16:36 PM
 */

package qltv;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import java.util.Calendar;

/**
 *
 * @author DELL
 */
public class QLTRASACH extends javax.swing.JFrame {

    /** Creates new form QLTRASACH */
    public QLTRASACH() {
        initComponents();
        loadqlts();  
    }

    private final String server = "THAOLE-VAIO";
    private final int port = 1433;
    private final String databaseName = "QLTHUVIEN_Nhom7_DACNPM";
    private final String username = "test";
    private final String password = "123456";
    Connection con = null;
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PNts = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        tb_qlts_madg = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        tb_qlts_tendg = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        tb_qlts_sosachmuon = new javax.swing.JTextField();
        cb_qlts_matsach = new javax.swing.JCheckBox();
        jLabel28 = new javax.swing.JLabel();
        tb_qlts_mas = new javax.swing.JTextField();
        jLabel29 = new javax.swing.JLabel();
        tb_qlts_songayquahan = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        tb_qlts_xuphat = new javax.swing.JTextField();
        bt_qlts_ktdg = new javax.swing.JButton();
        bt_qlts_kts = new javax.swing.JButton();
        bt_qlts_ts = new javax.swing.JButton();
        bt_qlts_huythaotac = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tb_xemkq = new javax.swing.JTable();
        btthoat = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        PNts.setBackground(new java.awt.Color(0, 51, 255));

        jLabel25.setText("Mã độc giả");

        jLabel26.setText("Tên độc giả");

        jLabel27.setText("Số sách mượn");

        cb_qlts_matsach.setText("mất sách");

        jLabel28.setText("Mã sách");

        jLabel29.setText("Số ngày quá hạn");

        jLabel30.setText("Xử phạt");

        bt_qlts_ktdg.setText("Kiểm tra độc giả");
        bt_qlts_ktdg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_qlts_ktdgActionPerformed(evt);
            }
        });

        bt_qlts_kts.setText("Kiểm tra sách");
        bt_qlts_kts.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_qlts_ktsActionPerformed(evt);
            }
        });

        bt_qlts_ts.setText("Trả sách");
        bt_qlts_ts.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_qlts_tsActionPerformed(evt);
            }
        });

        bt_qlts_huythaotac.setText("Hủy Thao Tác");
        bt_qlts_huythaotac.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_qlts_huythaotacActionPerformed(evt);
            }
        });

        tb_xemkq.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Mã Sách", "Tên Sách", "Ngày Mượn"
            }
        ));
        jScrollPane1.setViewportView(tb_xemkq);

        btthoat.setText("Thoát");
        btthoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btthoatActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PNtsLayout = new javax.swing.GroupLayout(PNts);
        PNts.setLayout(PNtsLayout);
        PNtsLayout.setHorizontalGroup(
            PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PNtsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PNtsLayout.createSequentialGroup()
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel25)
                            .addComponent(jLabel28))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(tb_qlts_mas)
                            .addComponent(tb_qlts_madg, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(34, 34, 34)
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel29)
                            .addComponent(jLabel26))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tb_qlts_tendg, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tb_qlts_songayquahan))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel27)
                            .addComponent(jLabel30))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PNtsLayout.createSequentialGroup()
                                .addComponent(tb_qlts_sosachmuon, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(cb_qlts_matsach))
                            .addComponent(tb_qlts_xuphat, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(PNtsLayout.createSequentialGroup()
                        .addComponent(bt_qlts_ktdg)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bt_qlts_kts, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(bt_qlts_ts)
                        .addGap(39, 39, 39)
                        .addComponent(bt_qlts_huythaotac)
                        .addGap(32, 32, 32)
                        .addComponent(btthoat))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        PNtsLayout.setVerticalGroup(
            PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PNtsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PNtsLayout.createSequentialGroup()
                        .addComponent(tb_qlts_madg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tb_qlts_mas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel29)
                            .addComponent(tb_qlts_songayquahan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tb_qlts_xuphat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel30)))
                    .addGroup(PNtsLayout.createSequentialGroup()
                        .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel25)
                            .addComponent(jLabel26)
                            .addComponent(jLabel27)
                            .addComponent(tb_qlts_sosachmuon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cb_qlts_matsach)
                            .addComponent(tb_qlts_tendg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel28)))
                .addGap(42, 42, 42)
                .addGroup(PNtsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bt_qlts_ktdg, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bt_qlts_kts)
                    .addComponent(bt_qlts_ts)
                    .addComponent(bt_qlts_huythaotac)
                    .addComponent(btthoat))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(39, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PNts, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PNts, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    int sosachmuon;
    String ngaymuonts;
    int monthm, daym, yearm;
    int songayquahan=0;


     String maphieu = "";
    int tienphat,giasach;
    boolean matsach = false;
    public void loadqlts()
    {
        tb_qlts_mas.setVisible(false);
        tb_qlts_songayquahan.setVisible(false);
        tb_qlts_xuphat.setVisible(false);
        cb_qlts_matsach.setVisible(false);
        bt_qlts_kts.setVisible(false);
        bt_qlts_ts.setVisible(false);
    }
   
    public void loadtb_qlts()
    {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            try {
                Connection con = DriverManager.getConnection(getURLConnection());
                Statement stm =con.createStatement();
                int i=0;
                ResultSet rs=stm.executeQuery("SELECT SACH.MASACH,SACH.TENSACH,PHIEUMUON.NGAYMUON FROM DOCGIA,PHIEUMUON,SACH_PHIEU,SACH WHERE DOCGIA.MADOCGIA='"+ tb_qlts_madg.getText() +"' AND DOCGIA.MADOCGIA=PHIEUMUON.MADOCGIA AND PHIEUMUON.MAPHIEU=SACH_PHIEU.MAPHIEU AND SACH_PHIEU.MASACH = SACH.MASACH AND SACH_PHIEU.NGAYTRA IS NULL");
                while(rs.next())
                {
                    tb_xemkq.setValueAt(rs.getString("MASACH"), i, 0);
                    tb_xemkq.setValueAt(rs.getString("TENSACH"), i, 1);
                    tb_xemkq.setValueAt(rs.getDate("NGAYMUON"), i, 2);                    
                    i++;                    
                }

                if(i<5)
                {
                    for(;i<5;i++)
                    {
                        tb_xemkq.setValueAt("", i, 0);
                        tb_xemkq.setValueAt("", i, 1);
                        tb_xemkq.setValueAt("", i, 2);
                    }
                }
            } catch (SQLException ex) {
                Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    int t=0;
    public void timxoavitrisach()
    {
        String masach1;
        for(int i=0;i<sosachmuon;i++)
        {
            masach1=""+tb_xemkq.getValueAt(i, 0);
            if(masach1.trim().equals(tb_qlts_mas.getText()))
            {
                t=i;
                //tb_xemkq.setValueAt("", i, 0);
                //tb_xemkq.setValueAt("", i, 1);
                //tb_xemkq.setValueAt("", i, 2);
            }
        }
        
        for(int i=t;i<4;i++)
        {
            tb_xemkq.setValueAt(tb_xemkq.getValueAt(i+1, 0), i, 0);
            tb_xemkq.setValueAt(tb_xemkq.getValueAt(i+1, 1), i, 1);
            tb_xemkq.setValueAt(tb_xemkq.getValueAt(i+1, 2), i, 2);
        }            
            tb_xemkq.setValueAt("", 4, 0);
            tb_xemkq.setValueAt("", 4, 1);
            tb_xemkq.setValueAt("", 4, 2);
    }
 
    private void bt_qlts_ktdgActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_qlts_ktdgActionPerformed
        // TODO add your handling code here:
        //tb_xemkq.removeAll();
        //tb_xemkq.removeEditor();
        int i=0;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            try {
                Connection con = DriverManager.getConnection(getURLConnection());
                Statement stm =con.createStatement();
                ResultSet rs=stm.executeQuery("SELECT DOCGIA.HOTEN FROM DOCGIA,PHIEUMUON,SACH_PHIEU,SACH WHERE DOCGIA.MADOCGIA='" + tb_qlts_madg.getText() + "' AND DOCGIA.MADOCGIA=PHIEUMUON.MADOCGIA AND PHIEUMUON.MAPHIEU=SACH_PHIEU.MAPHIEU AND SACH_PHIEU.MASACH = SACH.MASACH AND SACH_PHIEU.NGAYTRA IS NULL");
                while(rs.next()) {
                    tb_qlts_tendg.setText(rs.getString("HOTEN"));
                    i++;
                }
                tb_qlts_sosachmuon.setText(""+i);
                sosachmuon = i;
                tb_qlts_mas.setText("nhập mã sách");
                loadtb_qlts();
                //abc.setText(""+tb_xemkq.getY());
                tb_qlts_mas.setVisible(true);
                tb_qlts_madg.setVisible(false);
                bt_qlts_ts.setVisible(true);
                bt_qlts_ktdg.setVisible(false);
                bt_qlts_kts.setVisible(true);
                tb_qlts_xuphat.setVisible(true);
                tb_qlts_songayquahan.setVisible(true);

            } catch (SQLException ex) {
                Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_bt_qlts_ktdgActionPerformed

    private void bt_qlts_ktsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_qlts_ktsActionPerformed
        // TODO add your handling code here:
        Calendar c = Calendar.getInstance();
        int monthts = c.get(Calendar.MONTH)+1; //KO HIEU LY DO NO LAY THIEU 1 THANG TRONG THANG HE THONG
        int dayts = c.get(Calendar.DAY_OF_MONTH);
        int yearts = c.get(Calendar.YEAR);
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            try {
                Connection con = DriverManager.getConnection(getURLConnection());
                Statement stm =con.createStatement();
                ResultSet rs=stm.executeQuery("SELECT  NGAYHETHANTRA FROM SACH_PHIEU,SACH WHERE SACH.MASACH='" + tb_qlts_mas.getText() + "' AND SACH_PHIEU.MASACH = SACH.MASACH AND SACH_PHIEU.NGAYTRA IS NULL");
                while(rs.next()) {
                    ngaymuonts=""+rs.getDate("NGAYHETHANTRA");
                    //ngaymuon=Convert.ToString(dr["NGAYHETHANTRA"]);
                }
                //tb_qlts_songayquahan.setText(ngaymuon);
                yearm=Integer.parseInt(ngaymuonts.substring(0, 4));
                monthm=Integer.parseInt(ngaymuonts.substring(5,7));
                daym=Integer.parseInt(ngaymuonts.substring(8,10));
                songayquahan=monthts - monthm;
                songayquahan = (yearts - yearm) * 365 + (monthts - monthm) * 30 + (dayts - daym);
                if (songayquahan < 0)
                    songayquahan = 0;
                //SO NGAY QUA HAN KO NHA
                tb_qlts_songayquahan.setText(""+songayquahan);
                bt_qlts_ts.setVisible(true);

            } catch (SQLException ex) {
                Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_bt_qlts_ktsActionPerformed

    private void bt_qlts_tsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_qlts_tsActionPerformed
        // TODO add your handling code here:

        String xuphat;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            try {
                Connection con = DriverManager.getConnection(getURLConnection());
                Statement stm =con.createStatement();
                ResultSet rs = stm.executeQuery("SELECT PHIEUMUON.MAPHIEU,SACH.GIA FROM SACH,DOCGIA,PHIEUMUON,SACH_PHIEU WHERE DOCGIA.MADOCGIA='" + tb_qlts_madg.getText() + "' AND SACH.MASACH='"+ tb_qlts_mas.getText() + "' AND DOCGIA.MADOCGIA=PHIEUMUON.MADOCGIA AND PHIEUMUON.MAPHIEU=SACH_PHIEU.MAPHIEU AND SACH_PHIEU.MASACH=SACH.MASACH AND SACH_PHIEU.NGAYTRA IS NULL");
                while(rs.next()) {
                    maphieu = rs.getString("MAPHIEU");
                    giasach=rs.getInt("gia");
                }
                if(cb_qlts_matsach.isSelected()) {
                    xuphat = "MATSACH";
                    matsach = true;
                } else if (songayquahan > 0) {
                    xuphat = "TREHAN";
                } else xuphat = "";

                ResultSet rs1=stm.executeQuery("SELECT THAMSOXUPHAT.MUCPHAT FROM THAMSOXUPHAT WHERE THAMSOXUPHAT.TENXUPHAT='"+xuphat+ "'");
                while(rs1.next()) {
                    tienphat=rs1.getInt("MUCPHAT");
                }
                int mucphat = tienphat;

                if (xuphat.equals("MATSACH")) {
                    tienphat = tienphat * giasach;
                } else if(xuphat.equals("TREHAN"))
                    tienphat = tienphat * songayquahan;
                Calendar c = Calendar.getInstance();
                int mon=c.get(Calendar.MONTH)+1;
                String today = ""+ mon +"/"+c.get(Calendar.DAY_OF_MONTH)+"/"+c.get(Calendar.YEAR);
                phieusach ps = new phieusach();
                ps.set_maphieumuon(maphieu);
                ps.set_matsach(matsach);
                ps.set_ngaytra(today);
                ps.set_songayquahan(songayquahan);
                ps.set_tienphat(tienphat);
                ps.set_masach(tb_qlts_mas.getText());


                if (ps.trasach())
                {
                    if(matsach==true) {
                        JOptionPane.showMessageDialog(this, "Độc giả phải đền gấp "+mucphat+" lần giá trị quyển sách");
                        //MessageBox.Show("Độc giả phải đền gấp "+mucphat+" lần giá trị quyển sách", "Thông Báo");
                        sosachmuon--;
                        tb_qlts_xuphat.setText(""+ps.get_tienphat());
                        //tbxuphat.Text = Convert.ToString(ps.get_tienphat());
                    } else if (songayquahan > 0) {
                        JOptionPane.showMessageDialog(this, "Độc giả đã trả sách trễ hạn " + songayquahan + " ngày");
                        //MessageBox.Show("Độc giả đã trả sách trễ hạn " + songayquahan + " ngày", "Thông Báo");
                        sosachmuon--;
                        tb_qlts_xuphat.setText(""+ps.get_tienphat());
                    } else {
                        JOptionPane.showMessageDialog(this, "Đã trả sách thành công");
                        //MessageBox.Show("Đã trả sách thành công", "Thông Báo");
                        sosachmuon--;
                        tb_qlts_sosachmuon.setText(""+sosachmuon);
                    }
                    timxoavitrisach();

                } else     JOptionPane.showMessageDialog(this, "Có lỗi ko update được phiếu mượn");


            } catch (SQLException ex) {
                Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(QLTV.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_bt_qlts_tsActionPerformed
    private String getURLConnection() {
        return "jdbc:sqlserver://" + server + ":" + port +
                ";databaseName=" + databaseName +
                ";User=" + username +
                ";Password=" + password;
    }
    private void bt_qlts_huythaotacActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_qlts_huythaotacActionPerformed
        // TODO add your handling code here:
        tb_qlts_madg.setText("");
        tb_qlts_mas.setText("");
        tb_qlts_sosachmuon.setText("");
        tb_qlts_tendg.setText("");
        tb_qlts_songayquahan.setText("");
        tb_qlts_xuphat.setText("");
        cb_qlts_matsach.setSelected(false);
        tb_qlts_madg.setVisible(true);
        bt_qlts_ktdg.setVisible(true);
        tb_qlts_mas.setVisible(false);
        bt_qlts_ts.setVisible(false);
        bt_qlts_kts.setVisible(false);
        tb_qlts_songayquahan.setVisible(false);
        tb_qlts_xuphat.setVisible(false);
        for(int i=0;i<5;i++) {
            tb_xemkq.setValueAt("", i, 0);
            tb_xemkq.setValueAt("", i, 1);
            tb_xemkq.setValueAt("", i, 2);
        }
}//GEN-LAST:event_bt_qlts_huythaotacActionPerformed

    private void btthoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btthoatActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_btthoatActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new QLTRASACH().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel PNts;
    private javax.swing.JButton bt_qlts_huythaotac;
    private javax.swing.JButton bt_qlts_ktdg;
    private javax.swing.JButton bt_qlts_kts;
    private javax.swing.JButton bt_qlts_ts;
    private javax.swing.JButton btthoat;
    private javax.swing.JCheckBox cb_qlts_matsach;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField tb_qlts_madg;
    private javax.swing.JTextField tb_qlts_mas;
    private javax.swing.JTextField tb_qlts_songayquahan;
    private javax.swing.JTextField tb_qlts_sosachmuon;
    private javax.swing.JTextField tb_qlts_tendg;
    private javax.swing.JTextField tb_qlts_xuphat;
    private javax.swing.JTable tb_xemkq;
    // End of variables declaration//GEN-END:variables

}
